<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Sugar</title>
</head>

<body>
  <script>
    //     ### every 每一项
    //       ```js
    //        const 布尔值 = arr.every(item => 条件);
    //       ```
    //     MDN：https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/every
    //     注意点：
    //     1. 条件的每一项结果为 真值 ，最终才为`true`。如果有一项为假，结果就为假，并且停止。
    //     2. 若收到一个空数组，此方法在一切情况下都会返回`true`。


    const cartList = [
      { goods_id: 11, goods_name: '商品1', goods_selected: true },
      { goods_id: 33, goods_name: '商品3', goods_selected: true },
      { goods_id: 22, goods_name: '商品2', goods_selected: true },
      { goods_id: 44, goods_name: '商品4', goods_selected: true },
      { goods_id: 66, goods_name: '商品5', goods_selected: true },
    ]

    // debugger;
    // const selectedAll = cartList.every(item => {
    //   return item.goods_selected === true
    // })

    // 简化后
    const selectedAll = cartList.every(item => item.goods_selected)

    console.log(selectedAll);


  </script>
</body>

</html>